<script>
	export default {
		onLaunch: function() {
			let app = this;
			if (app.globalData.primary != 'blue') {
				uni.setNavigationBarColor({
					frontColor: '#ffffff',
					backgroundColor: '#ff7100',
					animation: {
						duration: 300
					},
					success: (ret) => {
						console.log(ret);
					},
					fail(err) {
						console.log(err);
					}
				})
			} else {
				uni.setNavigationBarColor({
					frontColor: '#ffffff',
					backgroundColor: '#2A79F2',
					animation: {
						duration: 300
					},
				})
			}
			app.$core.onRequestComplete(function(ret, response) {
				if (ret && ret.code === 401) {
					if (app.$core.getUserinfo()) {
						app.$core.logout();
						uni.navigateTo({
							url: '/pages/public/login'
						});
						uni.showToast({
							title: '登录过期,请重新登录',
							icon: 'none'
						});
					}
				}
			});
			setTimeout(function() {
				// app初始化完成后再执行
				let userinfo = app.$core.getUserinfo();
				if (userinfo) {
					app.globalData.userinfo = userinfo;
					app.$chatIM.connectSocket();
				}
				if(userinfo && userinfo.group_id == 2 && userinfo.group_model.audit_status != 1){
					//企业的身份时查询下状态
					app.$core.get({url: '/xilujob.company/company',loading: false,success(ret, data) {
						userinfo.group_model.audit_status = ret.data.userinfo.group_model.audit_status;
						app.$core.setUserinfo(userinfo);
					}
				});
				}
				
			}, 1);

		},
		globalData: {
			//小程序配置的接口请求域名，为项目部署的服务器路径
			primary: 'orange',
			// primary: 'blue',
			color: '#2A79F2',
			appid: '',
			wsDomain: 'wss://www.example.com:8301',
			apiBaseUri: "https://www.example.com/api",
			////前端上传图片补全域名，如oss的https://xxxx.oss-cn-shanghai.aliyuncs.com，或https://your.site.com
			storageBaseUri: "https://xwww.example.com",
			//阿里OSS的上传路径
			uploadOssStatus: false,
			alioss: {
				endpoint: 'https://bucket.oss-cn-shanghai.aliyuncs.com'
			},
			Events: {
				ConfigChange: "configChange",
				UserLogin: "userLogin",
				UserLogout: "userLogout",
				UserinfoChange: 'userinfoChange',
				UserinfoUpdate: "userinfoUpdate",
				UserProfileUpdate: "userProfileUpdate",
				UcenterInfoCompleteChange: "ucenterInfoCompleteChange",
				CurrentCityChange: 'currentCityChange',
				CurrentDistrictChange: 'currentDistrictChange',
				JobCreate: "jobCreate",
				JobUpdate: "jobUpdate",
				JobDelete: "jobDelete",
				InterviewCommentAdd: "interviewCommentAdd",
				ResumeFavAdd: "resumeFavAdd",
				ResumeFavRemove: "resumeFavRemove",
				JobFavAdd: 'JobFavAdd',
				JobFavRemove: 'JobFavRemove',
				CompanyFavRemove: "companyFavRemove",
				CompanyFavAdd: "companyFavAdd",
				ClearMessageCount: "clearMessageCount",
				RefreshUserCenter: "refreshUserCenter", //设置refresh标记，回到usercenter后刷新页面

				WebsocketMessageCount: 'websocketMessageCount'
			},
			config: {
				logo: '',
				platform_name: '',
				customer_qrcode: '',
				user_agreement: 0,
				privacy_agreement: 0
			},
			chat_config: {
				SocketTask: null,
				Timer: null,
				ErrorMsg: [],
				MaxRetryCount: 30, // 最大重连次数
				CurrentRetryCount: 0,
				ortherdata: null, //其他通用数据
				emoList: [], //表情
				messageCount: 0, //未读消息数
			},
			location: {
				latitude: '',
				longitude: ''
			},
			defaultCity: {
				id: 802,
				name: '上海市',
			}

		},
		onShow: function(e) {

			if (e.query) {
				if (e.query.scene) {
					let scene = decodeURIComponent(e.query.scene);
					let options = {}
					for (var i = 0; i < scene.split('&').length; i++) {
						var arr = scene.split('&')[i].split('=');
						options[arr[0]] = arr[1];
					}
					if (options.uid != 'undefined' && options.uid > 0) {
						try {
							uni.setStorageSync('recom_pid', options.uid);
						} catch (e) {
							//TODO handle the exception
							console.log(e);
						}

					}
					if (options.group != 'undefined') {
						try {
							uni.setStorageSync('recom_group', options.group)
						} catch (e) {
							//TODO handle the exception
							console.log(e);
						}
					
					}
				}

			}
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style lang="scss">
	@import "@/static/css/global.css";
	@import "@/uni_modules/uview-ui/index.scss";


	/* #ifdef APP-PLUS  || H5*/


	/deep/ .p_swiper .uni-swiper-dots {
		// 指示点整个区域
		right: 0;
		width: auto;
		left: auto;
	}

	/deep/ .find_swiper .uni-swiper-dots {
		// 指示点整个区域
		bottom: 62rpx;
	}

	.find_swiper .uni-swiper-dot-active {
		width: 30rpx;
		height: 15rpx;
		background: #FFFFFF;
		border-radius: 8rpx;
	}

	/* #endif */
	/* #ifdef MP-WEIXIN */

	.p_swiper .wx-swiper-dots.wx-swiper-dots-horizontal {

		right: 0;
		width: auto;
		left: auto;
	}

	.find_swiper .wx-swiper-dots.wx-swiper-dots-horizontal {
		bottom: 62rpx;

	}

	.find_swiper .wx-swiper-dot-active {
		width: 30rpx;
		height: 15rpx;
		background: #FFFFFF;
		border-radius: 8rpx;
	}

	/* #endif */
</style>